package components.photoTools
{
	import UIFree.ObjectEvent;
	import UIFree.controls.uif_button;
	import UIFree.controls.uif_imageButton;
	import UIFree.controls.uif_popupMenu;
	
	import UIPhoto.uip_events;
	import UIPhoto.uip_photoEditor;
	
	import classes.clt_events;
	import classes.clt_images;
	
	import components.clt_leftLeaveBlock;
	import components.clt_popupMenu;
	import components.clt_workspace;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class clt_photoTools extends clt_leftLeaveBlock {
		public function clt_photoTools(parent: uip_photoEditor, ax:int=0, ay:int=0) {
			super(parent, ax, ay, 32, 128);
		}
		
		override protected function createComponents(): void {
			var inner: Rectangle = block.getInner();
			new uif_imageButton(block, clt_images.c_flip_h, inner.x, inner.y, function(e: Event): void {
				parent.dispatchEvent(new Event(uip_events.FLIPH));
			});
			new uif_imageButton(block, clt_images.c_flip_v, inner.x, inner.y + 30, function(e: Event): void {
				parent.dispatchEvent(new Event(uip_events.FLIPV));
			});
			
			var sex: uif_imageButton = new uif_imageButton(block, clt_images.c_sex, inner.x, inner.y + 60, null);
			var _menu: clt_popupMenu = new clt_popupMenu(clt.popupMenuLayer, sex, [
				{caption: ' Шаблон для мужчин ', def: 0},
				{caption: ' Шаблон для женщин ', def: 1},
				{caption: ' Шаблон для подростка ', def: 3},
				{caption: ' Шаблон для ребенка ', def: 2}
			], function (e: ObjectEvent): void {
				workspace.dispatchEvent(new ObjectEvent(clt_events.SELECTTEMPLATE, e.object.def));
			});
			
			new uif_imageButton(block, clt_images.c_heads, inner.x, inner.y + 90, function(e: Event): void {
				workspace.dispatchEvent(new Event(clt_events.SHOWHEADS));
			});
		}
		
		protected function get workspace(): clt_workspace {
			return (app as clt_clothingBase).workspace;			
		}
	}
}